package com.tarena.lbs.article.web.service;

import com.tarena.lbs.article.web.repository.ArticleCategoryRepository;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.pojo.basic.po.ArticleCategoryPO;
import com.tarena.lbs.pojo.content.vo.ArticleCategoryVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class ArticleCategoryService {
    @Autowired
    private ArticleCategoryRepository articleCategoryRepository;

    public PageResult<ArticleCategoryVO> pageList() {
        //只查询 现有article_category表格所有数据局list
        PageResult<ArticleCategoryVO> voPage =
                new PageResult<>(10,1);
        voPage.setTotal(100l);
        List<ArticleCategoryPO> list = articleCategoryRepository.list();
        voPage.setObjects(list.stream().map(po->{
            ArticleCategoryVO vo=new ArticleCategoryVO();
            BeanUtils.copyProperties(po,vo);
            return vo;
        }).collect(Collectors.toList()));
        return voPage;
    }
}
